Olaf Klein contributes PathAway palm database reader
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 May 2005 16:14:08 +0000 (16:14 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 May 2005 16:14:08 +0000 (16:14 +0000)
gpsbabel/Makefile
gpsbabel/pathaway.c [new file with mode: 0644]
gpsbabel/reference/track/pathaway.mps [new file with mode: 0644]
gpsbabel/reference/track/pathaway.pdb [new file with mode: 0644]
gpsbabel/testo
gpsbabel/vecs.c

index 944dfe852272ef4dc5f597773cbe0c0d71dd22b9..2aca3cbd0c075ef4fa99fb02369a46c0a2350ed7 100644 (file)
@@ -28,7 +28,7 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \
        ozi.o nmea.o text.o html.o palmdoc.o netstumbler.o hsa_ndv.o \
        igc.o brauniger_iq.o shape.o hiketech.o glogbook.o coastexp.o \
        vcf.o overlay.o kml.o google.o lowranceusr.o an1.o tomtom.o \
-       tef_xml.o maggeo.o
+       tef_xml.o maggeo.o pathaway.o
 
 FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o
 
@@ -179,6 +179,8 @@ magnav.o: magnav.c defs.h queue.h gbtypes.h coldsync/palm.h \
 magproto.o: magproto.c defs.h queue.h gbtypes.h magellan.h
 main.o: main.c defs.h queue.h gbtypes.h
 tef_xml.o: tef_xml.c defs.h queue.h gbtypes.h xmlgeneric.h
+pathaway.o: pathaway.c defs.h queue.h gbtypes.h \
+  coldsync/palm.h coldsync/pdb.h
 mapsend.o: mapsend.c defs.h queue.h gbtypes.h mapsend.h magellan.h
 mapsource.o: mapsource.c defs.h queue.h gbtypes.h garmin_tables.h
 mkshort.o: mkshort.c defs.h queue.h gbtypes.h
diff --git a/gpsbabel/pathaway.c b/gpsbabel/pathaway.c
new file mode 100644 (file)
index 0000000..2e134ec
--- /dev/null
@@ -0,0 +1,121 @@
+/* 
+       Support for PathAway Palm Database, 
+       Copyright (C) 2005 Olaf Klein, o.b.klein@t-online.de
+
+       This program is free software; you can redistribute it and/or modify
+       it under the terms of the GNU General Public License as published by
+       the Free Software Foundation; either version 2 of the License, or
+       (at your option) any later version.
+
+       This program is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+       GNU General Public License for more details.
+
+       You should have received a copy of the GNU General Public License
+       along with this program; if not, write to the Free Software
+       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+*/
+
+#include "defs.h"
+#include "coldsync/palm.h"
+#include "coldsync/pdb.h"
+
+FILE *fd;
+
+#define MYNAME "pathaway pdb"
+#define MYTYPE                 0x55735472              /* ??? */
+#define MYCREATOR      0x4b6e5772              /* pathaway */
+
+/*
+ *
+ */
+
+static void
+ppdb_rd_init(const char *fname)
+{
+       fd = xfopen(fname, "rb", MYNAME);
+}
+
+/*
+ *
+ */
+static void
+ppdb_rd_deinit(void)
+{
+       fclose(fd);
+}
+
+/*
+ *
+ */
+
+static void
+ppdb_read(void)
+{
+       struct pdb *pdb;
+       struct pdb_record *pdb_rec;
+       char *data;
+       char latdir, longdir;
+       int latdeg, longdeg;
+       double latval, longval, altfeet;
+       struct tm dttm;
+
+       if (NULL == (pdb = pdb_Read(fileno(fd)))) {
+               fatal(MYNAME ": pdb_Read failed\n");
+       }
+
+       if ((pdb->creator != MYCREATOR) || (pdb->type != MYTYPE)) {
+               fatal(MYNAME ": Not a PathAway pdb file.\n");
+       }
+       
+       if (pdb->version != 3) {
+              fatal(MYNAME ": This file is from an untested version of PathAway and is unsupported.\n");
+        }
+
+       route_head *track_head = route_head_alloc();
+       track_add_head(track_head);
+
+       track_head->rte_name = xstrdup(pdb->name);
+
+       for (pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) 
+       {
+               waypoint *wpt_tmp = waypt_new();
+               data = (char *) pdb_rec->data;
+               memset(&dttm, 0, sizeof(dttm));
+               sscanf(data,"%c%d %lf,%c%d %lf,%lf,%02d%02d%02d %02d%02d%04d,",
+                   &latdir, &latdeg, &latval, &longdir, &longdeg, &longval, &altfeet, 
+                   &dttm.tm_hour, &dttm.tm_min, &dttm.tm_sec,
+                   &dttm.tm_mday, &dttm.tm_mon, &dttm.tm_year
+               );
+               
+               dttm.tm_year -= 1900;
+               dttm.tm_mon--;
+                   
+               wpt_tmp->creation_time = mktime(&dttm) + get_tz_offset();
+               
+               if (latdir == 'S') latdeg = -latdeg;
+               if (longdir == 'W') longdir = -longdir;
+               wpt_tmp->latitude = latdeg + (latval / 60.0);
+               wpt_tmp->longitude = longdeg + (longval / 60.0 );
+               wpt_tmp->altitude = altfeet / 3.2808;
+
+               route_add_wpt(track_head, wpt_tmp);             
+       } 
+       free_pdb(pdb);
+}
+
+ff_vecs_t ppdb_vecs = {
+       ff_type_file,
+       { ff_cap_none, ff_cap_read, ff_cap_none }, // We can only read track information
+       ppdb_rd_init,   
+       NULL,   
+       ppdb_rd_deinit,
+       NULL,
+       ppdb_read,
+       NULL,
+       NULL, 
+       NULL
+};
diff --git a/gpsbabel/reference/track/pathaway.mps b/gpsbabel/reference/track/pathaway.mps
new file mode 100644 (file)
index 0000000..79061fa
Binary files /dev/null and b/gpsbabel/reference/track/pathaway.mps differ
diff --git a/gpsbabel/reference/track/pathaway.pdb b/gpsbabel/reference/track/pathaway.pdb
new file mode 100644 (file)
index 0000000..5b86068
Binary files /dev/null and b/gpsbabel/reference/track/pathaway.pdb differ
index 06b36fe9f40abb024231f36bbae674f40b08846f..7382ede67d80e83b8d9e63cf2186aba2b1059786 100755 (executable)
@@ -694,4 +694,11 @@ rm -f ${TMPDIR}/tef_xms.mps
 ${PNAME} -r -i tef -f reference/route/tef_xml.sample.xml -o mapsource -F ${TMPDIR}/tef_xml.mps
 bincompare ${TMPDIR}/tef_xml.mps reference/route/tef_xml.mps
 
+#
+# pathaway palm database .pdb
+#
+rm -f ${TMPDIR}/pathaway.mps
+${PNAME} -t -i pathaway -f reference/track/pathaway.pdb -o mapsource -F ${TMPDIR}/pathaway.mps
+bincompare ${TMPDIR}/pathaway.mps reference/track/pathaway.mps
+
 exit 0
index cee2e7ff6441cd3f85970b81c897e140fa5add32..fd963f37755489b1ed7f860b3675e4e113d9df21 100644 (file)
@@ -80,6 +80,7 @@ extern ff_vecs_t maggeo_vecs;
 extern ff_vecs_t an1_vecs;
 extern ff_vecs_t tomtom_vecs;
 extern ff_vecs_t tef_xml_vecs;
+extern ff_vecs_t ppdb_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -384,6 +385,12 @@ vecs_t vec_list[] = {
                "Map&Guide 'TourExchangeFormat' XML",
                "xml"
        },
+       {
+               &ppdb_vecs,
+               "pathaway",
+               "PathAway Palm Database",
+               "pdb"
+       },
        {
                NULL,
                NULL,